{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "## 函数说明文档"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function str_max in module __main__:\n",
      "\n",
      "str_max(str1, str2)\n",
      "    比较两个字符串的大小\n",
      "    :param str1:\n",
      "    :param str2:\n",
      "    :return: 比较大的字符串\n",
      "\n",
      "\n",
      "    比较两个字符串的大小\n",
      "    :param str1:\n",
      "    :param str2:\n",
      "    :return: 比较大的字符串\n",
      "    \n"
     ]
    }
   ],
   "source": [
    "# 定义一个比较字符串大小的函数\n",
    "def str_max(str1, str2):\n",
    "    \"\"\"\n",
    "    比较两个字符串的大小\n",
    "    :param str1:\n",
    "    :param str2:\n",
    "    :return: 比较大的字符串\n",
    "    \"\"\"\n",
    "    str0 = str1 if str1 > str2 else str2\n",
    "    return str0\n",
    "\n",
    "help(str_max)\n",
    "\n",
    "print(str_max.__doc__)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8.249863\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "import random\n",
    "# 计算方差\n",
    "sum = 0\n",
    "num = 10000000\n",
    "for i in range(num):\n",
    "    sum += (random.randint(1, 10) - 5.5) ** 2\n",
    "print(sum / num)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}